home *** CD-ROM | disk | FTP | other *** search
/ Symantec Visual Cafe for Java 2.5 / symantec-visual-cafe-2.5-database-dev-edition.iso / Visual Cafe Pro v1.0 / SOURCE.BIN / Label.java < prev    next >
Encoding:
Java Source  |  1997-06-19  |  4.8 KB  |  143 lines

  1. /*
  2.  *
  3. */
  4.  
  5. package symantec.itools.db.awt;
  6.  
  7. import java.util.*;
  8. import symjava.sql.*;
  9. import java.lang.*;
  10. import symantec.itools.db.net.*;
  11. import symantec.itools.db.pro.*;
  12.  
  13. public class Label extends java.awt.Label implements ProjLink
  14. {
  15.     private ProjBinder m_ProjBinder;
  16.  
  17.     private String m_labelText;
  18.     private int    m_treatBlankAs = 0;
  19.     private boolean m_DynamicUpdate = false;
  20.  
  21.     public Label()
  22.     {
  23.         super("<dbAWARE Label>");
  24.     }
  25.  
  26.     public Label(String s)
  27.     {
  28.         super();
  29.         m_labelText = s;
  30.     }
  31.  
  32.     public void setBinding(RelationView relView, String projection)
  33.     {
  34.         try
  35.         {
  36.             int projectionNumber = relView.findProjByName(projection);
  37.             relView.bindProj(projectionNumber, this);
  38.         }
  39.         catch (SQLException Ex)
  40.         {
  41.             raiseException(
  42.                 "SQLException from Label.setBinding: "
  43.                 + Ex.getMessage());
  44.         }
  45.     }
  46.  
  47.     public void init (ProjBinder binder)
  48.     {
  49.         m_ProjBinder = binder;
  50.     }
  51.  
  52.     public void notifyDataChange(ProjBinder binder)
  53.     {
  54.         if (binder != null)
  55.         {
  56.             m_ProjBinder = binder;
  57.         }
  58.         String  data = new String();
  59.         try
  60.         {
  61.             if (binder.isReadable() && !binder.isNull())
  62.             {
  63.                 data = binder.getStringValue();
  64.             }
  65.         }
  66.         catch (SQLException Ex)
  67.         {
  68.             raiseException(
  69.                 "SQLException from Label.notifyDataChange: "
  70.                 + Ex.getMessage());
  71.         }
  72.         catch (java.io.IOException Ex)
  73.         {
  74.             raiseException(
  75.                 "IOException from Label.notifyDataChange: "
  76.                 + Ex.getMessage());
  77.         }
  78.         if (data.equals(""))
  79.         {
  80.             data = m_labelText;
  81.         }
  82.         setText(data);
  83.     }
  84.  
  85.     public boolean notifySetData(ProjBinder binder) throws SQLException
  86.     {
  87.         return true;
  88.     }
  89.  
  90.     public void setTreatBlankAs(String blank)
  91.     {
  92.         if (new String(blank).toUpperCase().equals("DEFAULT"))
  93.         {
  94.             m_treatBlankAs = RelationView.SETBLANKTODEFAULT;
  95.         }
  96.         else if (new String(blank).toUpperCase().equals("NULL"))
  97.             {
  98.                 m_treatBlankAs = RelationView.SETBLANKTONULL;
  99.             }
  100.             else if (new String(blank).toUpperCase().equals("BLANK"))
  101.             {
  102.                 m_treatBlankAs = RelationView.SETBLANKTOEMPTY;
  103.             }
  104.     }
  105.  
  106.     //*************************************************************************//
  107.     //                                                                         //
  108.     // FUNCTION: raiseException                                                //
  109.     //                                                                         //
  110.     //  PURPOSE:                                                               //
  111.     //                                                                         //
  112.     //  PARAMETERS:                                                            //
  113.     //                                                                         //
  114.     //  RETURNS:                                                               //
  115.     //                                                                         //
  116.     // COMMENTS:                                                               //
  117.     //                                                                         //
  118.     //*************************************************************************//
  119.  
  120.     void raiseException(String text)
  121.     {
  122.         System.out.println(text);
  123.     }
  124.  
  125.     //*************************************************************************//
  126.     //                                                                         //
  127.     // FUNCTION: setDynamicUpdate                                              //
  128.     //                                                                         //
  129.     //  PURPOSE:                                                               //
  130.     //                                                                         //
  131.     // PARAMETERS:                                                             //
  132.     //                                                                         //
  133.     //  RETURNS:                                                               //
  134.     //                                                                         //
  135.     // COMMENTS:                                                               //
  136.     //                                                                         //
  137.     //*************************************************************************//
  138.  
  139.     public void setDynamicUpdate(boolean update)
  140.     {
  141.         m_DynamicUpdate = update;
  142.     }
  143. }